package com.kws.merchant.controller;


import com.kws.merchant.domain.LoansInsurance;
import com.kws.merchant.domain.po.LoansInsurancePo;
import com.kws.merchant.service.LoansInsuranceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import com.kws.common.core.domain.R;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * 贷款-保险(LoansInsurance)表控制层
 *
 * @author yxy
 * @since 2024-10-29 14:45:42
 */
@RestController
@Api(tags = "贷款-保险(LoansInsurance)")
@RequestMapping("loansInsurance")
public class LoansInsuranceController {
    /**
     * 服务对象
     */
    @Resource
    private LoansInsuranceService loansInsuranceService;
 
    @PostMapping("/page")
    @ApiOperation(value = "分页查询列表")
    public R<Page<LoansInsurance>> pageList(@RequestBody LoansInsurancePo loansInsurancePo){
        return R.ok(loansInsuranceService.pageList(loansInsurancePo));
    }

    @GetMapping("/detailById/{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R<LoansInsurance> detailById(@PathVariable Long id) {
        return R.ok(loansInsuranceService.detailById(id));
    }


    @PostMapping("/add")
    @ApiOperation(value = "新增数据")
    public R add(@RequestBody LoansInsurance loansInsurance) {
        return R.ok(loansInsuranceService.save(loansInsurance));
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody LoansInsurance loansInsurance) {
        return R.ok(loansInsuranceService.updateById(loansInsurance));
    }


    @PostMapping("/delete")
    @ApiOperation(value = "删除数据")
    public R delete(@RequestBody List<Long> idList) {
        return R.ok(loansInsuranceService.removeByIds(idList));
    }
}
